home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #2 / Amiga Plus CD - 2004 - No. 02.iso / AmiSoft / Disk / moni / FileX-src.lha / FileX-src / mainwindow.c < prev    next >
C/C++ Source or Header  |  2004-01-07  |  23KB  |  1,063 lines

  1. /*
  2.  * MainWindow.c © 1993-1994 by Klaas Hermanns
  3.  *
  4.  * Funktionsübersicht:
  5.  *
  6.  * LONG OpenDisplay( void );                        Display öffnen
  7.  * BOOL CloseDisplay( void );                        Display schließen
  8.  * void ReopenDisplay( long );                    Display neu öffnen
  9.  * void DrawViewBoxes( void );                    Anzeigerahmen zeichnen
  10.  * void DoFontrequester( void );                    Fontrequester behandeln
  11.  * void SetScreenOwnPublic( void );                einem eigenen oder
  12.  * BOOL DoPubScreenListReq( void );                Publicscreen aus Liste
  13.  */
  14.  
  15. #include "FileXStructs.h"
  16. #include "FileXStrings.h"
  17. #include "FileX.h"
  18. #include "allprotos.h"
  19.  
  20.         /* Prototypes der lokalen Funktionen */
  21.  
  22. static int MySetupScreen( void );
  23. static LONG OpenFileXWindow( struct DisplayInhalt *DI );
  24.  
  25.         /* Variablen */
  26.  
  27. struct Screen *Scr;
  28. struct BitMap TempBM;
  29. struct RastPort TempRP;
  30. WORD TempBreite, TempHoehe;
  31.  
  32. WORD ScreenFlags = SF_DEFAULT_PUBLIC;        /* Screentyp, auf dem FileX liegt */
  33. char *SollPublicScreenName;
  34. APTR VisualInfo;            /* Zeiger auf das VisualInfo des Screens */
  35. struct ScreenModeData ScreenModeData;
  36.  
  37. struct ColorSpec ScreenColors[] = {
  38.     ~0, 0x00, 0x00, 0x00,
  39.      1, 0x00, 0x00, 0x00,
  40.      2, 0x00, 0x00, 0x00,
  41.      3, 0x00, 0x00, 0x00,
  42.      5, 0x00, 0x00, 0x00,
  43.      6, 0x00, 0x00, 0x00,
  44.      7, 0x00, 0x00, 0x00,
  45.      8, 0x00, 0x00, 0x00,
  46.     ~0, 0x00, 0x00, 0x00 };
  47.  
  48.  
  49. UWORD __chip Stopwatch[(1 + 16 + 1) * 2] =
  50. {
  51.     0x0000,0x0000,
  52.  
  53.     0x0400,0x07C0,
  54.     0x0000,0x07C0,
  55.     0x0100,0x0380,
  56.     0x0000,0x07E0,
  57.     0x07C0,0x1FF8,
  58.     0x1FF0,0x3FEC,
  59.     0x3FF8,0x7FDE,
  60.     0x3FF8,0x7FBE,
  61.     0x7FFC,0xFF7F,
  62.     0x7EFC,0xFFFF,
  63.     0x7FFC,0xFFFF,
  64.     0x3FF8,0x7FFE,
  65.     0x3FF8,0x7FFE,
  66.     0x1FF0,0x3FFC,
  67.     0x07C0,0x1FF8,
  68.     0x0000,0x07E0,
  69.  
  70.     0x0000,0x0000
  71. };
  72.  
  73. void FreeTempBitMap( void )
  74. {
  75.     if( TempBM.Planes[ 0 ])
  76.         FreeRaster( TempBM.Planes[ 0 ], TempBreite, TempHoehe );
  77. }
  78.  
  79. BOOL AllocTempBitMap( void )
  80. {
  81.     WORD Breite, Hoehe = 8;
  82.     struct DisplayInhalt *DI;
  83.     PLANEPTR NewPlane;
  84.  
  85.     if( !Scr )
  86.         return( TRUE );
  87.  
  88.     Breite = Scr->Width;
  89.  
  90.     DI = (struct DisplayInhalt *)DisplayInhaltList.lh_Head;
  91.  
  92.     while( DI != ( struct DisplayInhalt * )&DisplayInhaltList.lh_Tail )
  93.     {
  94.         if( DI->fhöhe > Hoehe )
  95.             Hoehe = DI->fhöhe;
  96.             
  97.         DI = ( struct DisplayInhalt *)DI->Node.ln_Succ;
  98.     }
  99.  
  100.     if( !( NewPlane = ( PLANEPTR )AllocRaster( Breite, Hoehe )))
  101.         return( FALSE );
  102.     else
  103.     {
  104.         FreeTempBitMap();
  105.         
  106.         TempBM.Planes[ 0 ] = NewPlane;
  107.         TempBreite = Breite;
  108.         TempHoehe = Hoehe;
  109.  
  110.         InitBitMap( &TempBM, 1, Breite, Hoehe );
  111.  
  112.         InitRastPort( &TempRP );
  113.         TempRP.BitMap = &TempBM;
  114.  
  115.         return( TRUE );
  116.     }
  117. }
  118.  
  119.     /* SetWaitPointer(struct Window *Window):
  120.      *
  121.      *    Set the busy wait mouse pointer.
  122.      */
  123.  
  124. void SetWaitPointer(struct Window *Window)
  125. {
  126.     if( Kick30 )
  127.     {
  128.         SetWindowPointer(Window,
  129.             WA_BusyPointer,        TRUE,
  130.             WA_PointerDelay,    TRUE,
  131.         TAG_DONE);
  132.     }
  133.     else
  134.         SetPointer(Window,Stopwatch,16,16,-6,0);
  135. }
  136.  
  137.     /* ClrWaitPointer(struct Window *Window):
  138.      *
  139.      *    Remove the busy wait mouse pointer.
  140.      */
  141.  
  142. void ClrWaitPointer(struct Window *Window)
  143. {
  144.     if(Kick30)
  145.         SetWindowPointer(Window,TAG_DONE);
  146.     else
  147.         ClearPointer(Window);
  148. }
  149.  
  150. static int BlockCount;
  151.  
  152.     /* BlockMainWindow()
  153.      *
  154.      * Blocks the mainwindows for any inputs. 
  155.      */
  156.  
  157. void BlockMainWindow( void )
  158. {
  159.     struct DisplayInhalt *DI;
  160.  
  161.     BlockCount++;
  162.  
  163.     if( BlockCount > 1 )
  164.         return;
  165.  
  166.     DI = (struct DisplayInhalt *)DisplayInhaltList.lh_Head;
  167.  
  168.     while( DI != ( struct DisplayInhalt * )&DisplayInhaltList.lh_Tail )
  169.     {
  170.         if( DI->Wnd )
  171.         {
  172.             DI->InvisibleRequest.RWindow = DI->Wnd;
  173.     
  174.                 /* Install the wait mouse pointer. */
  175.     
  176.             SetWaitPointer( DI->Wnd );
  177.     
  178.                 /* Install the requester if possible. */
  179.     
  180.             Request( &DI->InvisibleRequest, DI->Wnd );
  181.         }
  182.  
  183.         DI = ( struct DisplayInhalt *)DI->Node.ln_Succ;
  184.     }
  185. }
  186.  
  187. void ReleaseMainWindow( void )
  188. {
  189.     struct DisplayInhalt *DI;
  190.  
  191.     BlockCount--;
  192.  
  193.     if( BlockCount )
  194.         return;
  195.  
  196.     DI = (struct DisplayInhalt *)DisplayInhaltList.lh_Head;
  197.  
  198.     while( DI != ( struct DisplayInhalt * )&DisplayInhaltList.lh_Tail )
  199.     {
  200.             /* Restore the mouse pointer. */
  201.     
  202.         ClrWaitPointer( DI->Wnd );
  203.     
  204.             /* End the requester activity. */
  205.     
  206.         EndRequest( &DI->InvisibleRequest, DI->Wnd );
  207.     
  208.             /* Reset it to zeroes. */
  209.     
  210.         memset( &DI->InvisibleRequest, 0, sizeof( struct Requester ));
  211.  
  212.         DI = ( struct DisplayInhalt *)DI->Node.ln_Succ;
  213.     }
  214. }
  215.  
  216. void SetScreenModeData(    BOOL Valid,
  217.                                 ULONG DisplayID,
  218.                                 ULONG DisplayWidth,
  219.                                 ULONG DisplayHeight,
  220.                                 UWORD DisplayDepth,
  221.                                 UWORD OverscanType,
  222.                                 BOOL AutoScroll    )
  223. {
  224.     ScreenModeData.smd_Valid = Valid;
  225.     ScreenModeData.smd_DisplayID = DisplayID;
  226.     ScreenModeData.smd_DisplayWidth = DisplayWidth;
  227.     ScreenModeData.smd_DisplayHeight = DisplayHeight;
  228.     ScreenModeData.smd_DisplayDepth = DisplayDepth;
  229.     ScreenModeData.smd_OverscanType = OverscanType;
  230.     ScreenModeData.smd_AutoScroll = AutoScroll;
  231. }
  232.  
  233. /*
  234.  * int MySetupScreen( void )
  235.  * 
  236.  * Öffnet/Reserviert Screen und holt VisualInfo.
  237.  */
  238.  
  239. static int MySetupScreen( void )
  240. {
  241.         /* Sicherheitsabfrage: Falls Screen schon bereit, direkt zurück */
  242.  
  243.     if(Scr) return(0);
  244.  
  245.         /* Screen bereitstellen/öffnen und Scr-Zeiger setzen */
  246.  
  247.     switch( ScreenFlags )
  248.     {
  249.         case SF_WORKBENCH:
  250.             Scr = LockPubScreen("Workbench");
  251.             break;
  252.         case SF_PUBLIC:
  253.             Scr = LockPubScreen( SollPublicScreenName );
  254.             break;
  255.         case SF_OWN_PUBLIC:
  256.             {
  257.                 static char screenname[80];
  258.                 static UWORD pens[]={65535};
  259.                 char TempName[16];
  260.  
  261.                 if(filexid==0) strcpy(TempName,"FILEX");
  262.                 else sprintf(TempName,"FILEX.%ld",filexid);
  263.  
  264.                 sprintf(screenname,GetStr(MSG_SCREENTITLE),TempName);
  265.  
  266.                 Scr = OpenScreenTags(0L,
  267.                     SA_Title,    screenname,
  268.                     SA_Type,        PUBLICSCREEN,
  269.                     SA_Colors,    &ScreenColors[0],
  270.                     SA_Pens,        &pens[0],
  271.                     SA_SysFont,    1,
  272.                     SA_PubName,        TempName,
  273.                     SA_Width,        ScreenModeData.smd_DisplayWidth,
  274.                     SA_Height,        ScreenModeData.smd_DisplayHeight,
  275.                     SA_Depth,        ScreenModeData.smd_DisplayDepth,
  276.                     SA_DisplayID,    ScreenModeData.smd_DisplayID,
  277.                     SA_Overscan,    ScreenModeData.smd_OverscanType,
  278.                     SA_AutoScroll,    ScreenModeData.smd_AutoScroll,
  279.                     TAG_DONE);
  280.  
  281.                 if(!Scr)
  282.                 {
  283.                     Scr=LockPubScreen(NULL);
  284.                     ScreenFlags = SF_DEFAULT_PUBLIC;
  285.                 }
  286.                 else
  287.                 {
  288.                     PubScreenStatus(Scr,NULL);
  289.                 }
  290.             }
  291.             break;
  292.     }
  293.  
  294.     if(!Scr)
  295.     {
  296.         Scr=LockPubScreen(NULL);
  297.         ScreenFlags = SF_DEFAULT_PUBLIC;
  298.     }
  299.  
  300.     if(!Scr) return(1);
  301.  
  302.         /* VisualInfo für Gadgets, Menus und Bevelboxes ermitteln */
  303.  
  304.     if(!(VisualInfo=GetVisualInfo(Scr, TAG_DONE))) return(2);
  305.  
  306.     if( !AllocTempBitMap()) return( 3 );
  307.     
  308.     return(0);
  309. }
  310.  
  311.  
  312. /*
  313.  * LONG OpenDisplay()
  314.  * 
  315.  * Öffnet das Display, d.h. den Screen, alle Dateifenster
  316.  */
  317.  
  318. LONG OpenDisplay( void )
  319. {
  320.     ULONG err;
  321.     struct DisplayInhalt *DI;
  322.  
  323.     if( err = MySetupScreen())
  324.     {
  325.         MyRequest( MSG_INFO_GLOBAL_CANTSETUPSCREEN, err );
  326.         CloseDisplay();
  327.         return( 1L );
  328.     }
  329.  
  330.         /* Alle Windows öffnen und neuzeichnen */
  331.  
  332.     DI = (struct DisplayInhalt *)DisplayInhaltList.lh_Head;
  333.  
  334.     while( DI != ( struct DisplayInhalt * )&DisplayInhaltList.lh_Tail )
  335.     {
  336.         if(err = OpenFileXWindow( DI ))
  337.         {
  338.             if( err < 10 )
  339.                 MyRequest( MSG_INFO_GLOBAL_CANTOPENWINDOW, err );
  340.             else
  341.                 MyRequestNoLocale(( char * )err , 0 );
  342.  
  343.             CloseDisplay();
  344.             return( 2L );
  345.         }
  346.         else
  347.         {
  348.             struct DisplayData *DD;
  349.  
  350.             DD = ( struct DisplayData * )DI->DisplayList.lh_Head;
  351.  
  352.             while( DD != ( struct DisplayData * )&DI->DisplayList.lh_Tail )
  353.             {
  354.                 DD->Wnd = DI->Wnd;
  355.  
  356.                 DD = ( struct DisplayData *)DD->Node.ln_Succ;
  357.             }
  358.  
  359.             MakeDisplay( DI );
  360.         }
  361.  
  362.         DI = ( struct DisplayInhalt *)DI->Node.ln_Succ;
  363.     }
  364.     
  365.     ScreenToFront( Scr );
  366.  
  367.     return(0L);
  368. }
  369.  
  370. void CloseFileXWindow( struct DisplayInhalt *DI )
  371. {
  372.     if(DI->Wnd)
  373.     {
  374.         struct IntuiMessage    *IntuiMessage;
  375.         struct Node        *Successor;
  376.     
  377.             /* Doppelt gemoppelt hält besser */
  378.  
  379.         if( DI->Wnd->MenuStrip )
  380.             ClearMenuStrip( DI->Wnd );
  381.     
  382.             /* Falls wir ein AppWindow waren, dieses entfernen */
  383.  
  384.         if( DI->AppWnd )
  385.         {
  386.             RemoveAppWindow( DI->AppWnd );
  387.             DI->AppWnd = 0;
  388.         }
  389.  
  390.             /* Windowposition und -größe merken */
  391.  
  392.         DI->WindowLeft = DI->Wnd->LeftEdge;
  393.         DI->WindowTop = DI->Wnd->TopEdge;
  394.  
  395.             /* CLoseWindowSafely */
  396.  
  397.         Forbid();
  398.     
  399.         IntuiMessage = ( struct IntuiMessage * )DI->Wnd->UserPort->mp_MsgList.lh_Head;
  400.     
  401.         while( Successor = IntuiMessage->ExecMessage.mn_Node.ln_Succ )
  402.         {
  403.             if( IntuiMessage->IDCMPWindow == DI->Wnd )
  404.             {
  405.                 Remove(( struct Node * )IntuiMessage );
  406.     
  407.                 ReplyMsg(( struct Message * )IntuiMessage );
  408.             }
  409.     
  410.             IntuiMessage = ( struct IntuiMessage * ) Successor;
  411.         }
  412.     
  413.         DI->Wnd->UserPort = NULL;
  414.     
  415.         ModifyIDCMP( DI->Wnd, NULL );
  416.     
  417.         Permit();
  418.  
  419.         CloseWindow(DI->Wnd);
  420.         DI->Wnd = NULL;
  421.  
  422.             /* Alle Fensterzeiger der Displays löschen */
  423.             /* Alle PropGadgets freigeben */
  424.  
  425.         {
  426.             struct DisplayData *DD;
  427.  
  428.             DD = ( struct DisplayData * )DI->DisplayList.lh_Head;
  429.  
  430.             while( DD != ( struct DisplayData * )&DI->DisplayList.lh_Tail )
  431.             {
  432.                 DD->Wnd = 0;
  433.  
  434.                 if( DD->PropGadget )
  435.                 {
  436.                     if( DD->Wnd )
  437.                         RemoveGadget( DD->Wnd, DD->PropGadget );
  438.                     
  439.                     DisposeObject((APTR) DD->PropGadget );
  440.                     DD->PropGadget = 0;
  441.                 }
  442.  
  443.                 DD = ( struct DisplayData *)DD->Node.ln_Succ;
  444.             }
  445.         }
  446.     }
  447. }
  448.  
  449. /*
  450.  * BOOL CloseDisplay( void )
  451.  *
  452.  * Schließt alle DateiFenster und gibt Screen frei
  453.  */
  454.  
  455. BOOL CloseDisplay( void )
  456. {
  457.     struct DisplayInhalt *DI;
  458.  
  459.         /* Falls eigener Screen, prüfen, ob noch andere Windows */
  460.         /* auf ihm offen sind. Falls ja, FALSE zurückliefern */
  461.         /* Falls nein, Screen auf privat */
  462.  
  463.     if(Scr && (ScreenFlags == SF_OWN_PUBLIC))
  464.     {
  465.         struct List    *PubScreenList;
  466.         struct PubScreenNode    *ScreenNode;
  467.  
  468.         PubScreenList = LockPubScreenList();
  469.  
  470.         for(ScreenNode = (struct PubScreenNode *)PubScreenList -> lh_Head ; ScreenNode -> psn_Node . ln_Succ ; ScreenNode = (struct PubScreenNode *)ScreenNode -> psn_Node . ln_Succ)
  471.         {
  472.             if(ScreenNode -> psn_Screen == Scr)
  473.                 break;
  474.         }
  475.  
  476.         if(ScreenNode)
  477.         {
  478.             int EigeneFensterZahl = 0;
  479.  
  480.                 /* Zahl der von FileX geöffneten Fenster berechnen */
  481.  
  482.             DI = (struct DisplayInhalt *)DisplayInhaltList.lh_Head;
  483.  
  484.             while( DI != ( struct DisplayInhalt * )&DisplayInhaltList.lh_Tail )
  485.             {
  486.                 if( DI->Wnd )
  487.                     EigeneFensterZahl++;
  488.  
  489.                 DI = ( struct DisplayInhalt *)DI->Node.ln_Succ;
  490.             }
  491.  
  492.             if(ScreenNode -> psn_VisitorCount != EigeneFensterZahl )
  493.             {
  494.                 UnlockPubScreenList();
  495.  
  496.                 DisplayLocaleText( MSG_INFO_GLOBAL_SCREENUSED );
  497.  
  498.                 return(FALSE);
  499.             }
  500.             else
  501.             {
  502.                 Forbid();
  503.  
  504.                 UnlockPubScreenList();
  505.  
  506.                 PubScreenStatus(Scr,PSNF_PRIVATE);
  507.  
  508.                 Permit();
  509.             }
  510.         }
  511.         else
  512.             UnlockPubScreenList();
  513.     }
  514.  
  515.         /* Alle Windows schliessen */
  516.  
  517.     DI = (struct DisplayInhalt *)DisplayInhaltList.lh_Head;
  518.  
  519.     while( DI != ( struct DisplayInhalt * )&DisplayInhaltList.lh_Tail )
  520.     {
  521.         CloseFileXWindow( DI );
  522.         DI = ( struct DisplayInhalt *)DI->Node.ln_Succ;
  523.     }
  524.  
  525.     if(Scr)
  526.     {
  527.         MyFreeMenus();
  528.  
  529.             /* VisualInfo freigeben */
  530.  
  531.         if(VisualInfo)
  532.         {
  533.             FreeVisualInfo( VisualInfo);
  534.             VisualInfo=NULL;
  535.         }
  536.     
  537.             /* PublicScreen freigeben oder Screen schließen */
  538.  
  539.         switch( ScreenFlags )
  540.         {
  541.             case SF_WORKBENCH:
  542.             case SF_DEFAULT_PUBLIC:
  543.             case SF_PUBLIC:
  544.                 UnlockPubScreen(NULL,Scr);
  545.                 break;
  546.             case SF_OWN_PUBLIC:
  547.                 CloseScreen(Scr);
  548.                 break;
  549.         }
  550.  
  551.         Scr=NULL;
  552.     }
  553.  
  554.     return(TRUE);
  555. }
  556.  
  557. void SetSollPublicScreenName( char* Name )
  558. {
  559.     if( SollPublicScreenName )
  560.         FreeVec( SollPublicScreenName );
  561.  
  562.     if( SollPublicScreenName = AllocVec( strlen( Name ) + 1, MEMF_ANY ))
  563.     {
  564.         strcpy( SollPublicScreenName, Name );
  565.     }
  566. }
  567.  
  568. void SetScreenTypePublic( char *Name )
  569. {
  570.     SetSollPublicScreenName( Name );
  571.  
  572.         /* Falls Screen schon offen, neu öffnen */
  573.  
  574.     if( Scr ) ReopenDisplay( SF_PUBLIC );
  575.     else ScreenFlags = SF_PUBLIC;
  576. }
  577.  
  578. /*
  579.  * void ReopenDisplay(long type)
  580.  * 
  581.  * Schließt das FileXFenster, setzt den Screentype und öffnet
  582.  * das Display neu.
  583.  */
  584.  
  585. void ReopenDisplay( long type )
  586. {
  587.     long premf = mainflags;
  588.  
  589.     if( mainflags & MF_CLIPCONV )
  590.         CloseClipConv();
  591.  
  592.     if( mainflags & MF_CALC )
  593.         CloseCalc();
  594.  
  595.     if( CloseDisplay())
  596.     {
  597.         ScreenFlags = type;
  598.  
  599.         if( OpenDisplay())
  600.         {
  601.             CloseDisplay();
  602.             ScreenFlags = SF_WORKBENCH;
  603.             OpenDisplay();
  604.         }
  605.     }
  606.  
  607.     if( premf & MF_CLIPCONV )
  608.         OpenClipConv();
  609.  
  610.     if( premf & MF_CALC )
  611.         OpenCalc();
  612.  
  613.     ActivateWindow( AktuDI->Wnd );
  614. }
  615.  
  616. /*
  617.  * static LONG OpenFileXWindow( void )
  618.  * 
  619.  * Öffnet das HauptFileXWindow.
  620.  */
  621.  
  622. static LONG OpenFileXWindow( struct DisplayInhalt *DI )
  623. {
  624.         /* Sicherheitsabfrage: Falls das Window schon auf ist, direkt zurück */
  625.  
  626.     if( DI->Wnd ) return( 0L );
  627.  
  628.         /* Falls erstes Öffnen, Fenster unter Titelbar setzen */
  629.  
  630.     if( DI->WindowTop == -1 ) DI->WindowTop = Scr->WBorTop + Scr->RastPort.TxHeight + 1;
  631.  
  632.     if(!(DI->Wnd = OpenWindowTags(NULL,
  633.                 WA_Left,        DI->WindowLeft,
  634.                 WA_Top,        DI->WindowTop,
  635.                 WA_Title,    "FileX "VSTRING" © 1993-2004 Klaas Hermanns, Pavel Fedin",
  636.                 WA_InnerWidth,    GetFitWidth( DI ),
  637.                 WA_InnerHeight,GetFitHeight( DI ),
  638.                 WA_IDCMP,        0,
  639.                 WA_Flags,        WFLG_SIZEGADGET | WFLG_DRAGBAR | WFLG_DEPTHGADGET | WFLG_CLOSEGADGET | WFLG_SMART_REFRESH | WFLG_ACTIVATE | WFLG_NEWLOOKMENUS,
  640.                 WA_PubScreen,    Scr,
  641.                 WA_MaxWidth,    -1,
  642.                 WA_MaxHeight,    -1,
  643.                 TAG_DONE )))
  644.         return(4L);
  645.  
  646.     SetAPen( DI->Wnd->RPort, 1 );
  647.  
  648.         /* UserData auf zugehörigen DisplayInhalt setzen */
  649.  
  650.     DI->Wnd->UserData = ( APTR )DI;
  651.  
  652.         /* Globalen Windowport eintragen */
  653.  
  654.     DI->Wnd->UserPort = WndPort;
  655.  
  656. /*    ModifyIDCMP( DI->Wnd,-1 & (~(IDCMP_DELTAMOVE|IDCMP_INTUITICKS|IDCMP_MENUVERIFY))/*SCROLLERIDCMP | ARROWIDCMP | IDCMP_MENUPICK | IDCMP_CLOSEWINDOW | IDCMP_RAWKEY | IDCMP_VANILLAKEY | IDCMP_REFRESHWINDOW | IDCMP_IDCMPUPDATE | IDCMP_NEWSIZE | IDCMP_CHANGEWINDOW | IDCMP_SIZEVERIFY*/);*/
  657.  
  658.     ModifyIDCMP(    DI->Wnd,
  659.                         IDCMP_ACTIVEWINDOW |
  660.                         IDCMP_GADGETUP |
  661.                         IDCMP_GADGETDOWN |
  662.                         IDCMP_MOUSEMOVE |
  663.                         IDCMP_MENUPICK  |
  664.                         IDCMP_CLOSEWINDOW  |
  665.                         IDCMP_RAWKEY  |
  666.                         IDCMP_VANILLAKEY  |
  667.                         IDCMP_IDCMPUPDATE  |
  668.                         IDCMP_NEWSIZE  |
  669.                         IDCMP_MOUSEBUTTONS |
  670.                         IDCMP_INTUITICKS |
  671.                         IDCMP_SIZEVERIFY );
  672.         /* Versuchen ein AppWindow draus zu machen */
  673.  
  674.     DI->AppWnd = AddAppWindowA( 1, (ULONG)DI, DI->Wnd, AppPort, NULL );
  675.  
  676.         /* Window in den Prozess eintragen */
  677.  
  678. /*    (( struct Process * )FindTask( NULL ))->pr_WindowPtr = DI->Wnd;*/
  679.  
  680.         /* Menus setzen */
  681.  
  682.     if( !FileXMenus )
  683.         SetNewMenus();
  684.     else
  685.         SetMenuStrip(DI->Wnd, FileXMenus);
  686.  
  687.         /* Font setzen */
  688.  
  689.     if( DI->TextFont ) SetFont( DI->Wnd->RPort, DI->TextFont );
  690.  
  691.     return(0L);
  692. }
  693.  
  694. void MySetFont( struct TextAttr *ta, struct DisplayInhalt *DI )
  695. {
  696.     struct TextFont *OldTextFont = DI->TextFont;
  697.  
  698.     if( DI->TextFont = OpenDiskFont( ta ))
  699.     {
  700.         if( OldTextFont ) CloseFont( OldTextFont );
  701.  
  702.         DI->fhöhe = DI->TextFont->tf_YSize;
  703.         DI->fbase = DI->TextFont->tf_Baseline;
  704.         DI->fbreite = DI->TextFont->tf_XSize;
  705.  
  706.         AllocTempBitMap();
  707.  
  708.         if( DI->Wnd )
  709.         {
  710.             SetFont( DI->Wnd->RPort, DI->TextFont);
  711.  
  712.             MakeDisplay( DI );
  713.         }
  714.     }
  715.     else
  716.     {
  717.         DI->TextFont = OldTextFont;
  718.         MyFullRequest( MSG_INFO_GLOBAL_CANTOPENFONT, MSG_GADGET_CONTINUE, ta->ta_Name, ta->ta_YSize );
  719.     }
  720.  
  721. /*    Printf("MySetFont - TextFont %8lx OldFont %8lx\n", TextFont, OldTextFont );*/
  722. }
  723.  
  724. void MySetFontNameSize( char *Name, UWORD YSize, struct DisplayInhalt *DI )
  725. {
  726.     struct TextAttr ta;
  727.  
  728.     ta.ta_Name = Name;
  729.     ta.ta_YSize = YSize;
  730.     ta.ta_Style = 0;
  731.     ta.ta_Flags = 0;
  732.  
  733.     strcpy( DefaultFontName, Name );
  734.     DefaultFontSize = YSize;
  735.  
  736.     if( DI )
  737.         MySetFont( &ta, DI );
  738. }
  739.  
  740. void DoFontrequester( struct DisplayInhalt *DI )
  741. {
  742.     if( UseAsl )
  743.     {
  744.         struct FontRequester *Asl_FontReq;
  745.  
  746.         if( Asl_FontReq = (struct FontRequester *)
  747.                 AllocAslRequestTags(    ASL_FontRequest,
  748.                                             ASLFO_TitleText, GetStr( MSG_WINDOWTITLE_SELECTFONT ),
  749.                                             ASLFO_Flags, FOF_FIXEDWIDTHONLY,
  750.                                             TAG_DONE ))
  751.         {
  752.             if( AslRequestTags( Asl_FontReq,    ASLFO_Window, DI->Wnd,
  753.                                                         ASLFO_InitialName, DI->TextFont->tf_Message.mn_Node.ln_Name,
  754.                                                         ASLFO_InitialSize, DI->TextFont->tf_YSize,
  755.                                                         TAG_DONE ))
  756.             {
  757.                 MySetFont( &Asl_FontReq->fo_Attr, DI );
  758.             }
  759.  
  760.             FreeAslRequest( Asl_FontReq );
  761.         }
  762.         else
  763.             DisplayLocaleText( MSG_INFO_GLOBAL_CANTALLOCFONTREQ );
  764.     }
  765.     else
  766.     {
  767.         struct rtFontRequester *FontReq;
  768.  
  769.         if( FontReq = rtAllocRequestA( RT_FONTREQ, NULL ))
  770.         {
  771.             rtChangeReqAttr( FontReq,    RTFO_FontName, DI->TextFont->tf_Message.mn_Node.ln_Name,
  772.                                                 RTFO_FontHeight, DI->TextFont->tf_YSize,
  773.                                                 RTFO_FontStyle, 0,
  774.                                                 RTFO_FontFlags, 0,
  775.                                                 TAG_DONE );
  776.  
  777.             if( rtFontRequest( FontReq, GetStr( MSG_WINDOWTITLE_SELECTFONT ), RTFO_Flags, FREQF_FIXEDWIDTH | FREQF_SCALE, AktuDI->Wnd ? RT_Window : TAG_IGNORE, AktuDI->Wnd,TAG_DONE ))
  778.             {
  779.                 MySetFont( &FontReq->Attr, DI );
  780.             }
  781.  
  782.             rtFreeRequest( FontReq );
  783.         }
  784.         else
  785.             DisplayLocaleText( MSG_INFO_GLOBAL_CANTALLOCFONTREQ );
  786.     }
  787. }
  788.  
  789. void SetScreenOwnPublic( void )
  790. {
  791.     if( UseAsl && ( SysBase->LibNode.lib_Version >= 38 ))
  792.     {
  793.         struct ScreenModeRequester *Asl_ScreenModeReq;
  794.  
  795.         if( Asl_ScreenModeReq = (struct ScreenModeRequester *)
  796.                 AllocAslRequestTags(    ASL_ScreenModeRequest,
  797.                                             ASLFO_TitleText, GetStr( MSG_WINDOWTITLE_SCREENMODE ),
  798.                                             TAG_DONE ))
  799.         {
  800.             if( AslRequestTags(    Asl_ScreenModeReq,
  801.                                         ASLSM_Window, AktuDI->Wnd,
  802.                                         ASLSM_DoWidth, TRUE,
  803.                                         ASLSM_DoHeight, TRUE,
  804.                                         ASLSM_DoDepth, TRUE,
  805.                                         ASLSM_DoOverscanType, TRUE,
  806.                                         ASLSM_DoAutoScroll, TRUE,
  807.                                         ScreenModeData.smd_Valid ? TAG_IGNORE : TAG_DONE, 0,
  808.                                         ASLSM_InitialDisplayID, ScreenModeData.smd_DisplayID,
  809.                                         ASLSM_InitialAutoScroll, ScreenModeData.smd_AutoScroll,
  810.                                         ASLSM_InitialDisplayWidth, ScreenModeData.smd_DisplayWidth,
  811.                                         ASLSM_InitialDisplayHeight, ScreenModeData.smd_DisplayHeight,
  812.                                         ASLSM_InitialDisplayDepth, ScreenModeData.smd_DisplayDepth,
  813.                                         ASLSM_InitialOverscanType, ScreenModeData.smd_OverscanType,
  814.                                         TAG_DONE ))
  815.             {
  816.                 SetScreenModeData( TRUE, Asl_ScreenModeReq->sm_DisplayID, Asl_ScreenModeReq->sm_DisplayWidth, Asl_ScreenModeReq->sm_DisplayHeight, Asl_ScreenModeReq->sm_DisplayDepth, Asl_ScreenModeReq->sm_OverscanType, Asl_ScreenModeReq->sm_AutoScroll );
  817.                 ReopenDisplay( SF_OWN_PUBLIC );
  818.             }
  819.  
  820.             FreeAslRequest( Asl_ScreenModeReq );
  821.         }
  822.         else
  823.             DisplayLocaleText( MSG_INFO_GLOBAL_CANTALLOCSCREENMODEREQ );
  824.     }
  825.     else
  826.     if( ReqToolsBase )
  827.     {
  828.         struct rtScreenModeRequester *screenmodereq;
  829.     
  830.             /* Den Screenmoderequester allokieren */
  831.     
  832.         if( screenmodereq = rtAllocRequestA( RT_SCREENMODEREQ, NULL ))
  833.         {
  834.             if( ScreenModeData.smd_Valid )
  835.                 rtChangeReqAttr(screenmodereq,    RTSC_DisplayID, ScreenModeData.smd_DisplayID,
  836.                                                             RTSC_AutoScroll, ScreenModeData.smd_AutoScroll,
  837.                                                             RTSC_DisplayWidth, ScreenModeData.smd_DisplayWidth,
  838.                                                             RTSC_DisplayHeight, ScreenModeData.smd_DisplayHeight,
  839.                                                             RTSC_DisplayDepth, ScreenModeData.smd_DisplayDepth,
  840.                                                             RTSC_OverscanType, ScreenModeData.smd_OverscanType,
  841.                                                             TAG_END );
  842.     
  843.     
  844.             if( rtScreenModeRequest( screenmodereq, GetStr( MSG_WINDOWTITLE_SCREENMODE ), RTSC_Flags, SCREQF_OVERSCANGAD | SCREQF_AUTOSCROLLGAD | SCREQF_SIZEGADS | SCREQF_DEPTHGAD | SCREQF_GUIMODES, TAG_DONE ))
  845.             {
  846.                 SetScreenModeData( TRUE, screenmodereq->DisplayID, screenmodereq->DisplayWidth, screenmodereq->DisplayHeight, screenmodereq->DisplayDepth, screenmodereq->OverscanType, screenmodereq->AutoScroll );
  847.                 ReopenDisplay( SF_OWN_PUBLIC );
  848.             }
  849.     
  850.             rtFreeRequest(screenmodereq);
  851.         }    
  852.         else
  853.             DisplayLocaleText( MSG_INFO_GLOBAL_CANTALLOCSCREENMODEREQ );
  854.     }
  855.     else
  856.         DisplayLocaleText( MSG_INFO_GLOBAL_NOSCREENMODEREQ );
  857. }
  858.  
  859. /*
  860.  * static void FreeList(struct List *list)
  861.  *
  862.  * Gibt die gesamte Screenliste frei.
  863.  */
  864.  
  865. static void FreeList(struct List *list)
  866. {
  867.     struct Node *node;
  868.     while(!(IsListEmpty(list)))
  869.     {
  870.         node=list->lh_Head;
  871.         RemHead(list);
  872.         FreeMem(node->ln_Name,strlen(node->ln_Name)+1);
  873.         FreeMem(node,sizeof(struct Node));
  874.     }
  875.     FreeMem(list,sizeof(struct List));
  876. }
  877.  
  878. /*
  879.  * static BOOL AddNode(char *name,struct List *list)
  880.  *
  881.  * Fügt einen Namen in die Screenliste ein
  882.  */
  883.  
  884. static BOOL AddNode(char *name,struct List *list)
  885. {
  886.     struct Node *node;
  887.     if(node = AllocMem(sizeof(struct Node),MEMF_CLEAR))
  888.     if(node->ln_Name = AllocMem(strlen(name)+1,0))
  889.     {
  890.         strcpy(node->ln_Name,name);
  891.         AddTail(list,node);
  892.         return(TRUE);
  893.     }
  894.     else 
  895.     {
  896.         if(node)FreeMem(node,sizeof(struct Node));
  897.         return(FALSE);
  898.     }
  899. }
  900.  
  901. static void __saveds PubScreenListCallBack( struct List *List, struct Node *node )
  902. {
  903.     if( node )
  904.         SetScreenTypePublic( node->ln_Name );
  905.  
  906.     FreeList( List );
  907. }
  908.  
  909. BOOL OpenPubScreenListReq( void )
  910. {
  911.     struct List *ScrList;
  912.     char buffer[256];
  913.     struct List *PubList;
  914.     struct Node *node;
  915.     int Anzahl = 0;
  916.  
  917.     if(!(ScrList = AllocMem(sizeof(struct List),MEMF_CLEAR)))return(FALSE);
  918.     
  919.     ScrList->lh_Head=(struct Node *)&ScrList->lh_Tail;
  920.     ScrList->lh_Tail=0;
  921.     ScrList->lh_TailPred=(struct Node *)&ScrList->lh_Head;
  922.  
  923.     PubList=LockPubScreenList();
  924.     for(node=PubList->lh_Head;node->ln_Succ!=0;node=node->ln_Succ)
  925.     {
  926.         if(!(((struct PubScreenNode *)node)->psn_Flags&PSNF_PRIVATE))
  927.         {
  928.             strcpy(buffer,node->ln_Name);
  929.             AddNode(buffer,ScrList);
  930.             Anzahl++;
  931.         }
  932.     }
  933.     UnlockPubScreenList();
  934.  
  935.     if(!Anzahl)
  936.     {
  937.         DisplayLocaleText( MSG_INFO_GLOBAL_NONOTPRIVATEPUBLICSCREENSFOUND );
  938.         return( FALSE );
  939.     }
  940.     else
  941.         return( OpenListReq( ScrList, GetStr(MSG_WINDOWTITLE_PUBLICSCREENLIST), &PubScreenListCallBack ));
  942. }
  943.  
  944. /*******************************************************************/
  945.  
  946. void MyActivateWindow( struct DisplayInhalt *DI )
  947. {
  948.     AktuDI = DI;
  949.     AktuDD = DI->AktuDD;
  950.     SetDisplayCheckMarks();
  951. }
  952.  
  953. void ActivateNextWindow( void )
  954. {
  955.     struct DisplayInhalt *DI;
  956.  
  957.     DI = ( struct DisplayInhalt *)AktuDI->Node.ln_Succ;
  958.  
  959.     if( DI == (struct DisplayInhalt *)&DisplayInhaltList.lh_Tail )
  960.         DI = (struct DisplayInhalt *)DisplayInhaltList.lh_Head;
  961.  
  962.     if( DI != AktuDI )
  963.     {
  964.         if( AktuDI->Wnd->Flags & WFLG_WINDOWACTIVE )
  965.         {
  966.             ActivateWindow( DI->Wnd );
  967.             WindowToFront( DI->Wnd );
  968.         }
  969.         MyActivateWindow( DI );
  970.     }
  971. }
  972.  
  973. void ActivatePreviousWindow( void )
  974. {
  975.     struct DisplayInhalt *DI;
  976.  
  977.     DI = ( struct DisplayInhalt *)AktuDI->Node.ln_Pred;
  978.  
  979.     if( DI == (struct DisplayInhalt *)&DisplayInhaltList.lh_Head )
  980.         DI = (struct DisplayInhalt *)DisplayInhaltList.lh_TailPred;
  981.  
  982.     if( DI != AktuDI )
  983.     {
  984.         if( AktuDI->Wnd->Flags & WFLG_WINDOWACTIVE )
  985.         {
  986.             ActivateWindow( DI->Wnd );
  987.             WindowToFront( DI->Wnd );
  988.         }
  989.         MyActivateWindow( DI );
  990.     }
  991. }
  992.  
  993. BOOL OpenNewWindow( BOOL Split )
  994. {
  995.     BOOL Success = FALSE;
  996.     struct DisplayInhalt *DI;
  997.     struct FileData *FD;
  998.     struct DisplayData *OldDD;
  999.  
  1000.     DI = AllocDI();
  1001.  
  1002.     if( !Split )
  1003.     {
  1004.         FD = AllocFD( FD_FILE );
  1005.         strcpy( FD->Name, AktuDD->FD->Name );
  1006.         *(FilePart( FD->Name )) = 0;
  1007.     }
  1008.     else
  1009.         FD = AktuDD->FD;
  1010.  
  1011.     OldDD = AktuDD;
  1012.  
  1013.     if( DI->AktuDD = AllocDD( DI, FD ))
  1014.     {
  1015.         if( Split )
  1016.         {
  1017.             AktuDD->CPos = OldDD->CPos;
  1018.             AktuDD->SPos = OldDD->SPos;
  1019.             AktuDD->DisplayForm = OldDD->DisplayForm;
  1020.             AktuDD->DisplaySpaces = OldDD->DisplaySpaces;
  1021.         }
  1022.  
  1023.         MyActivateWindow( DI );
  1024.  
  1025.         if( 0 == OpenFileXWindow( DI ))
  1026.         {
  1027.             AktuDD->Wnd = DI->Wnd;
  1028.  
  1029.             MakeDisplay( DI );
  1030.  
  1031.             Success = TRUE;
  1032.         }
  1033.     }
  1034.  
  1035.     if( !Success )
  1036.     {
  1037.         FreeDI( DI );
  1038.         CloseFileXWindow( DI );
  1039.     }
  1040.  
  1041.     return( Success );
  1042. }
  1043.  
  1044. char *GetOwnScreenName( void )
  1045. {
  1046.     struct List *PubList;
  1047.     struct Node *node;
  1048.     char *name = NULL;
  1049.  
  1050.     PubList=LockPubScreenList();
  1051.     for(node=PubList->lh_Head;node->ln_Succ!=0;node=node->ln_Succ)
  1052.     {
  1053.         if((((struct PubScreenNode *)node)->psn_Screen == Scr ))
  1054.         {
  1055.             name =  node->ln_Name;
  1056.             break;
  1057.         }
  1058.     }
  1059.     UnlockPubScreenList();
  1060.  
  1061.     return( name );
  1062. }
  1063.